$(function () {

    /*linkman联系人*/
    $("#linkman").datagrid({
        fit: true,
        fitColumns: true,
        url: "/email/queryLinkman.do",
        singleSelect: "false",
        onSelect: function (index) {
            var row = $("#linkman").datagrid("getSelected");
            if (row.sourceEmp.id) {
                $.post("/email/queryEmailMessage.do", {sourceId: row.sourceEmp.id, id: row.id}, function (data) {
                    $("#getTime").attr("value", data.sendDate);
                    $("#getMessage").val(data.textarea);
                }, "json")
            }
            $("#linkman").datagrid('updateRow', {
                index: index,
                row: {
                    state: null
                }
            });
        },
        columns: [[
            {field: 'id', hidden: true},
            {
                field: 'id', hidden: true, formatter: function (value, row, index) {
                    return row.sourceEmp.id;
                }
            },
            {
                field: 'sourceEmp', title: '头像', align: "center", width: 100, formatter: function (value, row, index) {
                    return row.sourceEmp ? "<img  width= '30px'   src='" + row.sourceEmp.head + "' style='border-radius: 50%;border: 1px solid #ddd;' />" : row.head;
                }
            },
            {
                field: 'realname', title: '姓名', width: 50, align: "center", formatter: function (value, row, index) {
                    return row.sourceEmp ? row.sourceEmp.realname : row.sourceEmp;
                }
            },
            {
                field: 'state', title: '状态', width: 50, align: "center", formatter: function (value, row, index) {
                    return row.state ? "<font color='green'>未读</font>" : "已读";
                }
            },
        ]],
        toolbar: "#tools"
    });
    /*同事*/
    $("#colleague").datagrid({
        fit: true,
        fitColumns: true,
        singleSelect: "false",
        url: "/email/queryColleague.do",
        /* singleSelect: true,*/
        /*        onSelect: function () {
                    var row = entity_datagrid.datagrid("getSelected");
                    if (!row) {
                        $.messager.alert("温馨提示", "请在右边字典目录选择一条目录", "info");
                        return;
                    }
                    $("#dictionaryItem_datagrid").datagrid({url: "/systemDictionaryItem/query.do"});
                    $("#dictionaryItem_datagrid").datagrid("load", {sn: row.sn});
                },*/
        columns: [[
            {field: 'id', hidden: true},
            {
                field: 'head', title: '头像', align: "center", width: 100, formatter: function (head) {
                    console.log(head);
                    return head ? "<img  width= '30px'   src='" + head + "' style='border-radius: 50%;border: 1px solid #ddd;' />" : head;
                }
            },
            {field: 'realname', title: '姓名', width: 50, align: "center"},
        ]],
        toolbar: "#tools"
    });
});

